WndMain = {}

function WndMain.Show()
    local wnd = EDUI.Engine.FindWindow("WndMain")
    if not wnd then
        wnd = EDUI.Engine.LoadWindow("wnd/main.xml")
        if not wnd then return end

        local icon = EDUI.Engine.FindSurface("logo")
        wnd:SetIcon(icon)

        local minbtn = wnd:FindControl("min")
        if (minbtn) then
            minbtn:SetEvent("click", function(button)
                local wnd = button:GetWindow()
                wnd:MinWindow()
            end)
        end

        local closebtn = wnd:FindControl("close")
        if (closebtn) then
            closebtn:SetEvent("click", function(button)
                local wnd = button:GetWindow()
                wnd:Close()
            end)
        end

        wnd:AddTimer(500, function(id, interval, wnd)
            local time = wnd:FindControl("time")
            if time then
                time:SetText(os.date())
            end
            return interval
        end)
    end
    wnd:ShowWindow()
end